﻿using System;
using KLS.PPDS.Utility;

namespace KLS.PPDS.Core.Entity.BaseEntities
{
    public abstract class AuditEntity : Entity
    {
        
        public virtual DateTime? CreatedDate { get; set; }
        public virtual int? CreatedBy { get; set; }
        public virtual int? UpdatedBy { get; set; }
        public virtual DateTime? UpdatedDate { get; set; }
        public virtual bool IsDeleted { get; set; }

        public virtual void InitAudit()
        {
            CreatedDate = CreatedDate?? DateTime.Now;            
            CreatedBy = CommonSession.UserId;

            if (Id > 0)
            {
                UpdatedDate = DateTime.Now;                
                UpdatedBy = CreatedBy;
            }
        }
    }
}
